//
// Created by wxd on 2025/9/2.
//

#include "GeometryManager.h"

std::string GeometryManager::addGeo(const BaseGeometry &geo) {
    std::string traceId = geo.getTraceId();
    m_GeoMap.try_emplace(traceId, geo.clone());
    return traceId;
}

BaseGeometry *GeometryManager::getGeo(const std::string &geoId) {
    auto it = m_GeoMap.find(geoId);
    return it != m_GeoMap.end() ? it->second.get() : nullptr;
}

bool GeometryManager::removeGeo(const std::string &geoId) {
    if (const auto it = m_GeoMap.find(geoId); it != m_GeoMap.end()) {
        m_GeoMap.erase(it);
        return true;
    }
    return false;
}

bool GeometryManager::contain(const std::string &geoId) {
    return m_GeoMap.find(geoId) != m_GeoMap.end();
}

void GeometryManager::clear() {
    m_GeoMap.clear();
}